package com.yuxinmuyu.sports_management.controller.publicController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuxinmuyu.sports_management.bean.entiy.SportsProject;
import com.yuxinmuyu.sports_management.bean.entiy.SportsYear;
import com.yuxinmuyu.sports_management.bean.request.GetSportsProjectRequest;
import com.yuxinmuyu.sports_management.bean.request.PageRequest;
import com.yuxinmuyu.sports_management.bean.response.SportsInfoResponse;
import com.yuxinmuyu.sports_management.exception.R;
import com.yuxinmuyu.sports_management.service.SportsYearService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sportsYear")
@Api(value = "历史运动会",tags = {"历史运动会"})
public class SportsYearController {
    @Resource
    SportsYearService sportsYearService;

    @ApiOperation("获取历史运动会")
    @PostMapping("/adm/getSportsYear")
    public R<Page<SportsYear>>getSportsYear(@RequestBody @Validated PageRequest request){
        return R.success(sportsYearService.getSportsYear(request));
    }

    @ApiOperation("添加历史运动会")
    @PostMapping("/adm/addSportsYear")
    public R<?>addSportsYear(@RequestBody @Validated SportsYear sportsYear){
        sportsYearService.addSportsYear(sportsYear);
        return R.success("添加成功!");
    }

    @ApiOperation("获取运动会项目信息")
    @PostMapping("/getProject")
    public R<Page<SportsInfoResponse>>getPage(@RequestBody @Validated GetSportsProjectRequest request){
        return R.success(sportsYearService.selectPage(request));
    }
}
